From 95e2089220e5deb8b060ebcc75a184064cc41c4f Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Tue, 8 Sep 2015 10:39:15 -0700 Subject: [PATCH] Don't capture rustdoc output for transitive deps We already started doing this for the compiler awhile back, so this just brings rustdoc up to the same parity --- src/cargo/ops/cargo_rustc/mod.rs | 24 ++++------------------ tests/test_cargo_doc.rs | 34 ++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 20 deletions(-) diff --git a/src/cargo/ops/cargo_rustc/mod.rs b/src/cargo/ops/cargo_rustc/mod.rs index ab0887864..a13a74dc0 100644 --- a/src/cargo/ops/cargo_rustc/mod.rs +++ b/src/cargo/ops/cargo_rustc/mod.rs @@ -8,7 +8,7 @@ use std::sync::Arc; use core::{SourceMap, Package, PackageId, PackageSet, Target, Resolve}; use core::{Profile, Profiles}; -use util::{self, CargoResult, human, caused_human}; +use util::{self, CargoResult, human}; use util::{Config, internal, ChainError, Fresh, profile, join_paths}; use self::job::{Job, Work}; @@ -533,31 +533,15 @@ fn rustdoc(package: &Package, target: &Target, profile: &Profile, trace!("commands={}", rustdoc); - let primary = package.package_id() == cx.resolve.root(); let name = package.name().to_string(); let desc = rustdoc.to_string(); let exec_engine = cx.exec_engine.clone(); Ok(Work::new(move |desc_tx| { desc_tx.send(desc).unwrap(); - if primary { - try!(exec_engine.exec(rustdoc).chain_error(|| { - human(format!("Could not document `{}`.", name)) - })) - } else { - try!(exec_engine.exec_with_output(rustdoc).and(Ok(())).map_err(|err| { - match err.exit { - Some(..) => { - caused_human(format!("Could not document `{}`.", - name), err) - } - None => { - caused_human("Failed to run rustdoc", err) - } - } - })) - } - Ok(()) + exec_engine.exec(rustdoc).chain_error(|| { + human(format!("Could not document `{}`.", name)) + }) })) } diff --git a/tests/test_cargo_doc.rs b/tests/test_cargo_doc.rs index 6def20ba2..57d37129d 100644 --- a/tests/test_cargo_doc.rs +++ b/tests/test_cargo_doc.rs @@ -1,3 +1,5 @@ +use std::str; + use support::{project, execs, path2url}; use support::{COMPILING, RUNNING}; use hamcrest::{assert_that, existing_file, existing_dir, is_not}; @@ -314,6 +316,38 @@ test!(target_specific_not_documented { execs().with_status(0)); }); +test!(output_not_captured { + let p = project("foo") + .file("Cargo.toml", r#" + [package] + name = "foo" + version = "0.0.1" + authors = [] + + [dependencies] + a = { path = "a" } + "#) + .file("src/lib.rs", "") + .file("a/Cargo.toml", r#" + [package] + name = "a" + version = "0.0.1" + authors = [] + "#) + .file("a/src/lib.rs", " + /// ``` + /// ☃ + /// ``` + pub fn foo() {} + "); + + let output = p.cargo_process("doc").exec_with_output().err().unwrap() + .output.unwrap(); + let stderr = str::from_utf8(&output.stderr).unwrap(); + assert!(stderr.contains("☃"), "no snowman\n{}", stderr); + assert!(stderr.contains("unknown start of token"), "no message\n{}", stderr); +}); + test!(target_specific_documented { let p = project("foo") .file("Cargo.toml", &format!(r#" -- 2.30.2